/*
This file analyzes the dataset for Feyman et al. Medicaid Managed Care Organizations’ Participation Reduces Marketplace Premiums: A Quasi-Experimental Study
*/
clear all
set more off

***ANALYSIS STARTS HERE***
use "full_data_combined_analytic.dta", clear
bysort fips year: gen fips_unique=1 if _n==1

//identify sample
egen missing=rowmiss(lag_mco_instr_ra lag_mco lag_hhi metalcrosswalksort plancode mkt_share med_income perc_unins perc_poverty black_share female_share over65_share unemp hpsa penetration monopoly lag_enroll_share)
gen in_sample=1 if missing==0

//add inflation adjustment factors to 2020 dollars
gen inf_adj=1 if year==2020
replace inf_adj=1.02 if year==2019
replace inf_adj=1.04 if year==2018
replace inf_adj=1.06 if year==2017
replace inf_adj=1.09 if year==2016
replace inf_adj=1.1 if year==2015
replace inf_adj=1.1 if year==2014

//identify single rating-area states
egen tag=tag(state year ratingarea2)
bysort state year: egen ra_count=total(tag)

//descriptives

***T-Test Comparing MMCO and non-MMCO
ttest premiumadultindividualage40, by(mmco)

***Figure 1 and 2***
gen mmco2=mmco*100
graph bar (mean) mmco2 if year!=2014, over(year) ytitle(% MMCO Plans) b1title(Plan year)
graph export "Fig1.png", as(png) replace
graph bar (mean) mco_penetration if fips_unique==1 & year!=2014, over(year) ytitle(% MMCO Penetration)  b1title(Plan year)
graph export "Fig2.png", as(png) replace

***Table 1***
putexcel set "table1.xlsx", replace
putexcel A2=("MMCO") A3=("Non-MMCO") A5=("Plan Type") A6=("EPO") A7=("HMO") A8=("POS") A9=("PPO") A11=("Metal Tier") ///
A12=("Bronze") A13=("Silver") A14=("Gold") A15=("Platinum")
putexcel B1=("2015") C1=("2016") D1=("2017") E1=("2018") F1=("2019") G1=("2020")
local inner=66
local col=char(`inner')
local row=2
local cell="`col'`row'"
//MCOs
forval i=2015/2020 {
	sum premiumadultindividualage40 if mmco==1 & year==`i'
	local mean round(r(mean))
	local sd round(r(sd))
	local a: di `mean' " (" `sd' ")"
	putexcel `cell'="`a'"
	local ++inner
	local col=char(`inner')
	local cell="`col'`row'"
}
local inner=66
local col=char(`inner')
local ++row
local cell="`col'`row'"
//Non-MCOs
forval i=2015/2020 {
	sum premiumadultindividualage40 if mmco==0 & year==`i'
	local mean round(r(mean))
	local sd round(r(sd))
	local a: di `mean' " (" `sd' ")"
	putexcel `cell'="`a'"
	local ++inner
	local col=char(`inner')
	local cell="`col'`row'"
}
local inner=66
local col=char(`inner')
local ++row
local ++row
local ++row
local cell="`col'`row'"
//EPOs
forval i=2015/2020 {
	sum premiumadultindividualage40 if plancode==1 & year==`i'
	local mean round(r(mean))
	local sd round(r(sd))
	local a: di `mean' " (" `sd' ")"
	putexcel `cell'="`a'"
	local ++inner
	local col=char(`inner')
	local cell="`col'`row'"
}
local inner=66
local col=char(`inner')
local ++row
local cell="`col'`row'"
//HMOs
forval i=2015/2020 {
	sum premiumadultindividualage40 if plancode==2 & year==`i'
	local mean round(r(mean))
	local sd round(r(sd))
	local a: di `mean' " (" `sd' ")"
	putexcel `cell'="`a'"
	local ++inner
	local col=char(`inner')
	local cell="`col'`row'"
}
local inner=66
local col=char(`inner')
local ++row
local cell="`col'`row'"
//POSs
forval i=2015/2020 {
	sum premiumadultindividualage40 if plancode==3 & year==`i'
	local mean round(r(mean))
	local sd round(r(sd))
	local a: di `mean' " (" `sd' ")"
	putexcel `cell'="`a'"
	local ++inner
	local col=char(`inner')
	local cell="`col'`row'"
}
local inner=66
local col=char(`inner')
local ++row
local cell="`col'`row'"
//PPOs
forval i=2015/2020 {
	sum premiumadultindividualage40 if plancode==4 & year==`i'
	local mean round(r(mean))
	local sd round(r(sd))
	local a: di `mean' " (" `sd' ")"
	putexcel `cell'="`a'"
	local ++inner
	local col=char(`inner')
	local cell="`col'`row'"
}
local inner=66
local col=char(`inner')
local ++row
local ++row
local ++row
local cell="`col'`row'"
//Bronze
forval i=2015/2020 {
	sum premiumadultindividualage40 if metalcrosswalksort==1 & year==`i'
	local mean round(r(mean))
	local sd round(r(sd))
	local a: di `mean' " (" `sd' ")"
	putexcel `cell'="`a'"
	local ++inner
	local col=char(`inner')
	local cell="`col'`row'"
}
local inner=66
local col=char(`inner')
local ++row
local cell="`col'`row'"
//Silver
forval i=2015/2020 {
	sum premiumadultindividualage40 if metalcrosswalksort==2 & year==`i'
	local mean round(r(mean))
	local sd round(r(sd))
	local a: di `mean' " (" `sd' ")"
	putexcel `cell'="`a'"
	local ++inner
	local col=char(`inner')
	local cell="`col'`row'"
}
local inner=66
local col=char(`inner')
local ++row
local cell="`col'`row'"
//Gold
forval i=2015/2020 {
	sum premiumadultindividualage40 if metalcrosswalksort==3 & year==`i'
	local mean round(r(mean))
	local sd round(r(sd))
	local a: di `mean' " (" `sd' ")"
	putexcel `cell'="`a'"
	local ++inner
	local col=char(`inner')
	local cell="`col'`row'"
}
local inner=66
local col=char(`inner')
local ++row
local cell="`col'`row'"
//Platinum
forval i=2015/2020 {
	sum premiumadultindividualage40 if metalcrosswalksort==4 & year==`i'
	local mean round(r(mean))
	local sd round(r(sd))
	local a: di `mean' " (" `sd' ")"
	putexcel `cell'="`a'"
	local ++inner
	local col=char(`inner')
	local cell="`col'`row'"
}
local inner=66
local col=char(`inner')
local ++row
local cell="`col'`row'"

//regressions
eststo clear

//OLS - insurer fixed effects, monopoly
reghdfe premiumadultindividualage40 lag_hhi i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share lag_mco if in_sample==1 & monopoly==1, absorb(year fips ins_id state#year) cluster(fips)
eststo ols_monopoly
outreg2 [ols_monopoly] using "reg_output.xls", excel bracket replace alpha(0.001, 0.01, 0.05) addtext(Insurer FE, YES, Instrument, NONE, Spillover, N/A, Monopoly, YES, HHI, YES)

//OLS - insurer fixed effects, no monopoly
reghdfe premiumadultindividualage40 lag_hhi i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share lag_mco if in_sample==1 & monopoly==0, absorb(year fips ins_id state#year) cluster(fips)
eststo ols_no_monopoly
outreg2 [ols_no_monopoly] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addtext(Insurer FE, YES, Instrument, NONE, Spillover, N/A, Monopoly, NO, HHI, YES)

//OLS - insurer fixed effects, no HHI, monopoly
reghdfe premiumadultindividualage40 i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share lag_mco if in_sample==1 & monopoly==1, absorb(year fips ins_id state#year) cluster(fips)
eststo ols_monopoly_nohhi
outreg2 [ols_monopoly_nohhi] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addtext(Insurer FE, YES, Instrument, NONE, Spillover, N/A, Monopoly, YES, HHI, NO)

//OLS - insurer fixed effects, no HHI, no monopoly
reghdfe premiumadultindividualage40 i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share lag_mco if in_sample==1 & monopoly==0, absorb(year fips ins_id state#year) cluster(fips)
eststo ols_no_monopoly_nohhi
outreg2 [ols_no_monopoly_nohhi] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addtext(Insurer FE, YES, Instrument, NONE, Spillover, N/A, Monopoly, NO, HHI, NO)

//2SLS - insurer fixed effects, monopoly
ivreghdfe premiumadultindividualage40 lag_hhi i.metalcrosswalksort i.plancode med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share (lag_mco =lag_mco_instr_ra) if in_sample==1 & monopoly==1, absorb(year fips ins_id state#year) cluster(fips) first
eststo tsls_monopoly, addscalars(FStat e(widstat))
outreg2 [tsls_monopoly] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addstat(FStat, e(FStat)) addtext(Insurer FE, YES, Instrument, RATING AREA, Spillover, N/A, Monopoly, YES, HHI, YES)

//2SLS - insurer fixed effects, no monopoly
ivreghdfe premiumadultindividualage40 lag_hhi i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share (lag_mco =lag_mco_instr_ra) if in_sample==1 & monopoly==0, absorb(year fips ins_id state#year) cluster(fips) first
eststo tsls_no_monopoly, addscalars(FStat e(widstat))
outreg2 [tsls_no_monopoly] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addstat(FStat, e(FStat)) addtext(Insurer FE, YES, Instrument, RATING AREA, Spillover, N/A, Monopoly, NO, HHI, YES)

//2SLS - insurer fixed effects, no HHI, monopoly
ivreghdfe premiumadultindividualage40 i.metalcrosswalksort i.plancode med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share (lag_mco =lag_mco_instr_ra) if in_sample==1 & monopoly==1, absorb(year fips ins_id state#year) cluster(fips) first
eststo tsls_monopoly_nohhi, addscalars(FStat e(widstat))
outreg2 [tsls_monopoly_nohhi] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addstat(FStat, e(FStat)) addtext(Insurer FE, YES, Instrument, RATING AREA, Spillover, N/A, Monopoly, YES, HHI, NO)

//2SLS - insurer fixed effects, no HHI, no monopoly
ivreghdfe premiumadultindividualage40 i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share (lag_mco =lag_mco_instr_ra) if in_sample==1 & monopoly==0, absorb(year fips ins_id state#year) cluster(fips) first
eststo tsls_no_monopoly_nohhi, addscalars(FStat e(widstat))
outreg2 [tsls_no_monopoly_nohhi] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addstat(FStat, e(FStat)) addtext(Insurer FE, YES, Instrument, RATING AREA, Spillover, N/A, Monopoly, NO, HHI, NO)

***SPILLOVER ANALYSIS: EXCLUDE MCOS***
//OLS exclude MCOs, monopoly
reghdfe premiumadultindividualage40 lag_hhi i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share lag_mco if in_sample==1 & mmco!=1 & monopoly==1, absorb(year fips state#year ins_id) cluster(fips)
eststo ols_no_mco1
outreg2 [ols_no_mco1] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addtext(Insurer FE, YES, Instrument, NONE, Spillover, EXLUDE MCO, Monopoly, YES, HHI, YES )

//OLS exclude MCOs, no monopoly
reghdfe premiumadultindividualage40 lag_hhi i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share lag_mco if in_sample==1 & mmco!=1 & monopoly==0, absorb(year fips state#year ins_id) cluster(fips)
eststo ols_no_mco2
outreg2 [ols_no_mco2] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addtext(Insurer FE, YES, Instrument, NONE, Spillover, EXLUDE MCO, Monopoly, NO, HHI, YES)

//OLS exclude MCOs, no HHI, monopoly
reghdfe premiumadultindividualage40 i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share lag_mco if in_sample==1 & mmco!=1 & monopoly==1, absorb(year fips state#year ins_id) cluster(fips)
eststo ols_no_mco3
outreg2 [ols_no_mco3] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addtext(Insurer FE, YES, Instrument, NONE, Spillover, EXLUDE MCO, Monopoly, YES, HHI, NO)

//OLS exclude MCOs, no HHI, no monopoly
reghdfe premiumadultindividualage40 i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share lag_mco if in_sample==1 & mmco!=1 & monopoly==0, absorb(year fips state#year ins_id) cluster(fips)
eststo ols_no_mco4
outreg2 [ols_no_mco4] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addtext(Insurer FE, YES, Instrument, NONE, Spillover, EXLUDE MCO, Monopoly, NO, HHI, NO)

//2SLS - exclude MCOs, monopoly
ivreghdfe premiumadultindividualage40 lag_hhi i.metalcrosswalksort i.plancode med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share  (lag_mco =lag_mco_instr_ra) if in_sample==1 & mmco!=1 & monopoly==1, absorb(year fips state#year ins_id) cluster(fips) first
eststo tsls_no_mco1, addscalars(FStat e(widstat))
outreg2 [tsls_no_mco1] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addstat(FStat, e(FStat)) addtext(Insurer FE, YES, Instrument, RATING AREA, Spillover, EXLUDE MCO, Monopoly, YES, HHI, YES)

//2SLS - exclude MCOs, no monopoly
ivreghdfe premiumadultindividualage40 lag_hhi i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share  (lag_mco =lag_mco_instr_ra) if in_sample==1 & mmco!=1 & monopoly==0, absorb(year fips state#year ins_id) cluster(fips) first
eststo tsls_no_mco2, addscalars(FStat e(widstat))
outreg2 [tsls_no_mco2] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addstat(FStat, e(FStat)) addtext(Insurer FE, YES, Instrument, RATING AREA, Spillover, EXLUDE MCO, Monopoly, NO, HHI, YES)

//2SLS - exclude MCOs, no HHI, monopoly
ivreghdfe premiumadultindividualage40  i.metalcrosswalksort i.plancode med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share  (lag_mco =lag_mco_instr_ra) if in_sample==1 & mmco!=1 & monopoly==1, absorb(year fips state#year ins_id) cluster(fips) first
eststo tsls_no_mco3, addscalars(FStat e(widstat))
outreg2 [tsls_no_mco3] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addstat(FStat, e(FStat)) addtext(Insurer FE, YES, Instrument, RATING AREA, Spillover, EXLUDE MCO, Monopoly, YES, HHI, NO)

//2SLS - exclude MCOs, no HHI, no monopoly
ivreghdfe premiumadultindividualage40 i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share  (lag_mco =lag_mco_instr_ra) if in_sample==1 & mmco!=1 & monopoly==0, absorb(year fips state#year ins_id) cluster(fips) first
eststo tsls_no_mco4, addscalars(FStat e(widstat))
outreg2 [tsls_no_mco4] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addstat(FStat, e(FStat)) addtext(Insurer FE, YES, Instrument, RATING AREA, Spillover, EXLUDE MCO, Monopoly, NO, HHI, NO)

***SPILOVER ANALYSIS: BENCHMARK***

//OLS benchmark, monopoly
ivreghdfe benchmarkpremiumehb lag_hhi med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share lag_mco if in_sample==1 & fips_unique==1 & monopoly==1, absorb(year fips state#year) cluster(fips) first
eststo ols_bmark1
outreg2 [ols_bmark1] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addtext(Insurer FE, YES, Instrument, NO, Spillover, BENCHMARK, Monopoly, YES, HHI, YES)

//OLS benchmark, no monopoly
ivreghdfe benchmarkpremiumehb lag_hhi med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share lag_mco if in_sample==1 & fips_unique==1 & monopoly==0, absorb(year fips state#year) cluster(fips) first
eststo ols_bmark2
outreg2 [ols_bmark2] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addtext(Insurer FE, YES, Instrument, NO, Spillover, BENCHMARK, Monopoly, NO, HHI, YES)

//OLS benchmark, no HHI, monopoly
ivreghdfe benchmarkpremiumehb  med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share lag_mco if in_sample==1 & fips_unique==1 & monopoly==1, absorb(year fips state#year) cluster(fips) first
eststo ols_bmark3
outreg2 [ols_bmark3] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addtext(Insurer FE, YES, Instrument, NO, Spillover, BENCHMARK, Monopoly, YES, HHI, NO)

//OLS benchmark, no HHI, no monopoly
ivreghdfe benchmarkpremiumehb med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share lag_mco if in_sample==1 & fips_unique==1 & monopoly==0, absorb(year fips state#year) cluster(fips) first
eststo ols_bmark4
outreg2 [ols_bmark4] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addtext(Insurer FE, YES, Instrument, NO, Spillover, BENCHMARK, Monopoly, NO, HHI, NO)

//2SLS benchmark, monopoly
ivreghdfe benchmarkpremiumehb lag_hhi med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share  (lag_mco =lag_mco_instr_ra) if in_sample==1 & fips_unique==1 & monopoly==1, absorb(year fips state#year) cluster(fips) first
eststo tsls_bmark1, addscalars(FStat e(widstat))
outreg2 [tsls_bmark1] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addstat(FStat, e(FStat)) addtext(Insurer FE, YES, Instrument, RATING AREA, Spillover, BENCHMARK, Monopoly, YES, HHI, YES)

//2SLS benchmark, no monopoly
ivreghdfe benchmarkpremiumehb lag_hhi med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share  (lag_mco =lag_mco_instr_ra) if in_sample==1 & fips_unique==1 & monopoly==0, absorb(year fips state#year) cluster(fips) first
eststo tsls_bmark2, addscalars(FStat e(widstat))
outreg2 [tsls_bmark2] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addstat(FStat, e(FStat)) addtext(Insurer FE, YES, Instrument, RATING AREA, Spillover, BENCHMARK, Monopoly, NO, HHI, YES)

//2SLS benchmark, no HHI, monopoly
ivreghdfe benchmarkpremiumehb med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share  (lag_mco =lag_mco_instr_ra) if in_sample==1 & fips_unique==1 & monopoly==1, absorb(year fips state#year) cluster(fips) first
eststo tsls_bmark3, addscalars(FStat e(widstat))
outreg2 [tsls_bmark3] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addstat(FStat, e(FStat)) addtext(Insurer FE, YES, Instrument, RATING AREA, Spillover, BENCHMARK, Monopoly, YES, HHI, NO)

//2SLS benchmark, no HHI, no monopoly
ivreghdfe benchmarkpremiumehb med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share  (lag_mco =lag_mco_instr_ra) if in_sample==1 & fips_unique==1 & monopoly==0, absorb(year fips state#year) cluster(fips) first
eststo tsls_bmark4, addscalars(FStat e(widstat))
outreg2 [tsls_bmark4] using "reg_output.xls", excel bracket append alpha(0.001, 0.01, 0.05) addstat(FStat, e(FStat)) addtext(Insurer FE, YES, Instrument, RATING AREA, Spillover, BENCHMARK, Monopoly, NO, HHI, NO)


//ADDITIONAL ANALYSES
cap erase "alt_models.xls"
cap erase "alt_models.txt"
eststo clear

//same year penetration

//2SLS - insurer fixed effects, HHI, no monopoly
ivreghdfe premiumadultindividualage40 lag_hhi i.metalcrosswalksort i.plancode med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share c.mkt_share##i.mkt_share_med lag_hhi (mco_penetration =mco_instr_ra) if monopoly==0, absorb(year fips ins_id state#year) cluster(fips)
eststo tsls_same_year, addscalars(FStat e(widstat))
outreg2 [tsls_same_year] using "alt_models.xls", excel bracket append alpha(0.001, 0.01, 0.05) addstat(FStat, e(FStat)) addtext(Insurer FE, YES, Instrument, SAME YEAR RATING AREA, Spillover, NO, Monopoly, NO, HHI, YES)

//2SLS - insurer fixed effects, HHI, no monopoly, no MCO
ivreghdfe premiumadultindividualage40 lag_hhi i.metalcrosswalksort i.plancode med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share c.mkt_share##i.mkt_share_med lag_hhi (mco_penetration =mco_instr_ra) if monopoly==0 & mmco==0, absorb(year fips ins_id state#year) cluster(fips)
eststo tsls_same_year_spill, addscalars(FStat e(widstat))
outreg2 [tsls_same_year_spill] using "alt_models.xls", excel bracket append alpha(0.001, 0.01, 0.05) addstat(FStat, e(FStat)) addtext(Insurer FE, YES, Instrument, SAME YEAR RATING AREA, Spillover, EXCLUDE MCO, Monopoly, NO, HHI, YES)

//inflation adjust main model
preserve
replace premiumadultindividualage40=premiumadultindividualage40*inf_adj
replace med_income=med_income*inf_adj
ivreghdfe premiumadultindividualage40 lag_hhi i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share lag_hhi (lag_mco =lag_mco_instr_ra) if in_sample==1 & monopoly==0, absorb(year fips ins_id state#year) cluster(fips) first
eststo inflation_main, addscalars(FStat e(widstat))
outreg2 [inflation_main] using "alt_models.xls", excel bracket append alpha(0.001, 0.01, 0.05) addtext(Insurer FE, YES, Instrument, N/A, Spillover, NO, Monopoly, NO, HHI, YES)
restore

//primary model, only MMCO
ivreghdfe premiumadultindividualage40 lag_hhi i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share (lag_mco =lag_mco_instr_ra) if in_sample==1 & monopoly==0 & mmco==1, absorb(year fips ins_id state#year) cluster(fips) first

//first stage for table 3

//no hhi, no monopoly
reghdfe lag_mco lag_mco_instr_ra i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share if in_sample==1 & monopoly==0, absorb(year fips state#year ins_id) cluster(fips)

ivreghdfe premiumadultindividualage40 i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share  (lag_mco =lag_mco_instr_ra) if in_sample==1 & monopoly==0, absorb(year fips state#year ins_id) cluster(fips) first

//no hhi, no monopoly, spillover
ivreghdfe premiumadultindividualage40 i.metalcrosswalksort i.plancode c.mkt_share##i.mkt_share_med med_income perc_unins perc_poverty black_share female_share over65_share unemp i.hpsa penetration lag_enroll_share  (lag_mco =lag_mco_instr_ra) if in_sample==1 & mmco!=1 & monopoly==0, absorb(year fips state#year ins_id) cluster(fips) first

//examine market entry
preserve
keep if in_sample==1
bysort year fips ins_id: keep if _n==1
bysort year fips: egen sum_mmco=total(mmco)
bysort year fips: keep if _n==1
sort fips year
gen entry=0
by fips: replace entry=1 if sum_mmco[_n]>sum_mmco[_n-1]
restore
